home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 5
/
Aminet 5 - March 1995.iso
/
Aminet
/
util
/
pack
/
ULIB3954.lha
/
UnpackLib
/
Examples
/
Example1.S
< prev
next >
Wrap
Text File
|
1992-09-02
|
4KB
|
164 lines
; Unpack.library Example #1: Show Crunchers
;
INCDIR "Includes1.3:Include1.3/"
INCLUDE "Own/Unpack.i"
INCLUDE "Libraries/Dos_lib.i"
INCLUDE "Exec/Exec_lib.i"
START move.l 4.w,a6
moveq #0,d0
lea dosname(pc),a1
jsr _LVOOpenLibrary(a6) ;Open Dos.library
move.l d0,dosbase
beq doserr
moveq #34,d0
lea unpname(pc),a1
jsr _LVOOpenLibrary(a6) ;Open Unpack.library V34+
move.l d0,unpbase
bne unpok
; Error While Opening The Unpack.library
move.l dosbase(pc),a6
jsr _LVOOutPut(a6) ;Get The CLI Window File Handler
move.l d0,d1 ;File Handler
move.l #unperrt,d2 ;Pointer To Error Text
moveq #33,d3 ;Length Of Text
jsr _LVOWrite(a6) ;Write Text In Window
bra unperr
; Every Thing Are OK!
UNPOK bsr main ;Jump To Main Routine
move.l 4.w,a6
move.l unpbase(pc),a1
jsr _LVOCloseLibrary(a6) ;Close Unpack.library
UNPERR move.l 4.w,a6
move.l dosbase(pc),a1
jsr _LVOCloseLibrary(a6) ;Close Dos.library
DOSERR moveq #0,d0
rts
;------------------------------------------------------------------------------
; Main Routine
;
MAIN move.l dosbase(pc),a6
move.l #winname,d1 ;Window Name
move.l #1005,d2 ;Mode: Old
jsr _LVOOpen(a6) ;Open A Window
move.l d0,winhd
beq winerr
move.l unpbase(pc),a6
jsr AllocCInfo(a6) ;Allocate Cruncher Info Structure
move.l d0,cinfo
beq cinferr
; Initialize
move.w #1,crunum ;Initialize Start Number
moveq #1,d7 ;Initialize Number Of Lines
move.l cinfo(pc),a0
jsr UnpackList(a6) ;Get Pointer To First Name
move.l a1,pactxt ;And Store It
lea txtstr(pc),a0
bsr print ;Print Name
addq.w #1,crunum ;Count Cruncher Number
; Loop
LOOP move.l unpbase(pc),a6
move.l cinfo(pc),a0
jsr UnpackListNext(a6) ;Get Pointer To Next Name
beq finish ;No More Crunchers
move.l a1,pactxt
lea txtstr(pc),a0
bsr print
addq.w #1,crunum ;Count Cruncher Number
addq.w #1,d7 ;Count Number Of Lines
cmp.w #12,d7 ;Printed 12 Lines?
bne loop ;Nip, One More
moveq #-1,d0
FINISH move.w d0,-(sp)
lea txtstr1(pc),a0
bsr print ;Print "Press RETURN"
move.l dosbase(pc),a6
move.l winhd(pc),d1
move.l #txtstrn,d2
moveq #1,d3
jsr _LVORead(a6) ;Wait For A Return?
lea txtstr2(pc),a0
bsr print ;Clear Window
moveq #0,d7
move.w (sp)+,d0
tst.w d0 ;Finished?
bne loop ;Nup!
move.l unpbase(pc),a6
move.l cinfo(pc),a0
jsr FreeCInfo(a6) ;Free Cruncher Info Structure Again
CINFERR move.l dosbase(pc),a6
move.l winhd(pc),d1
jsr _LVOClose(a6) ;Close Window Again
WINERR rts
;------------------------------------------------------------------------------
; Print Routine
;
; IN : A0 = Pointer To A String
;
PRINT move.l 4.w,a6
clr.l txtlen ;Clear Text Length
lea crunum(pc),a1
lea print1(pc),a2
lea txtstrn(pc),a3
jsr _LVORawDoFmt(a6) ;Format String
move.l dosbase(pc),a6
move.l winhd(pc),d1
move.l #txtstrn,d2
move.l txtlen(pc),d3
jsr _LVOWrite(a6) ;Write Text In Window
rts
PRINT1 move.b d0,(a3)+ ;Store Character In Buffer
addq.l #1,txtlen
rts
;------------------------------------------------------------------------------
DOSBASE dc.l 0
UNPBASE dc.l 0
WINHD dc.l 0
CINFO dc.l 0
TXTLEN dc.l 0
CRUNUM dc.w 1
PACTXT dc.l 0
;------------------------------------------------------------------------------
DOSNAME dc.b "dos.library",0
UNPNAME dc.b "unpack.library",0
WINNAME dc.b "CON:120/64/400/128/"
dc.b "Crunchers the unpack.library can unpack....",0
;------------------------------------------------------------------------------
UNPERRT dc.b "You need the unpack.library V34+",10
TXTSTR dc.b "%3d - %s",10,0
TXTSTR1 dc.b 10,"Press RETURN....",0
TXTSTR2 dc.b 12,0
TXTSTRN blk.b 40,0
even
;------------------------------------------------------------------------------
SLUT